#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
use Illuminate\Console\Application;
use Webman\Config;
use Dotenv\Dotenv;
use support\bootstrap\db\Laravel;

$container = new Container;
$events = new Dispatcher($container);

$artisan = new Application($container, $events, 'Version 1');
$artisan->setName('webman command');

if (method_exists('Dotenv\Dotenv', 'createUnsafeImmutable')) {
    Dotenv::createUnsafeImmutable(base_path())->load();
} else {
    Dotenv::createMutable(base_path())->load();
}
Config::load(config_path(), ['route', 'container']);
$bootstrap = Config::get('bootstrap');
foreach ($bootstrap as $class) {
    $class::start(null);
}
$artisan->resolveCommands(config('command'));
$artisan->setCatchExceptions(true);
$artisan->run();
